#include <iostream>
using namespace std;
//空指针调用成员函数
class Person{
public:
    Person();
    void showClassName()
    {
        cout<<"this is a Person Class"<<endl;
    }
    void showPersonAge() const{//添加const属性值不可被修改 this指针本质是指针常量，指向不可修改，内容可以修改 成员函数后加const本质是修饰this指针，让指针指向的值不可修改
        if (this == NULL)
        {
            return;
        }
        m_Age = 100;//Person *const this;
        x_Age = 250;
        cout<<"age="<<m_Age<<endl;
    }
    int m_Age;
    mutable int x_Age;//添加mutable可以修改
};
void Test01()
{
    Person *p = NULL;
    p->showClassName();
    p->showPersonAge();
}
void Test02()
{
    const Person p;
    p.m_Age = 100;
    p.x_Age = 100;
    //常对象只能调用常函数
    p.showPersonAge();
    p.showClassName();
}
int main() {
    Test01();
    return 0;
}
